package com.codingTrick;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class TestForIterator {
	public void traditionalFor(){
		for(int i =5 ;i<10; i++){
		}
	}
	
	public void advanceFor(){
		List list = new ArrayList();
		for(Object obj : list){
			
		}
		/*
		Object obj;
		for (Iterator iterator = list.iterator(); iterator.hasNext();) {
			obj = iterator.next();
			System.out.println(obj.toString());
		}*/
	}
	
/*高级for有一个局限性。必须有被遍历的目标。    
	建议在遍历数组的时候，还是希望是用传统for。因为传统for可以定义脚标。*/
	
	
	public static void main(String[] args) {
		List list = new ArrayList();
		Object obj;
		for (Iterator iterator = list.iterator(); iterator.hasNext();) {
			obj = iterator.next();
			System.out.println(obj.toString());
		}
	}
}
